﻿<Window x:Class="MassRenamer.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	    xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
	    xmlns:host="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
		xmlns:this="clr-namespace:MassRenamer"
        Title="MassRenamer" 
		Icon="/MassRenamer;component/renamer.ico"
		Closing="Window_Closing" >
	
	<Window.Resources>
		
		<this:FileNameValueConverter x:Name="fileNameValueConverter"
									 x:Key="fileNameValueConverter" />

		<DataTemplate x:Name="fileWithoutPathDataTemplate"
					  x:Key="fileWithoutPathDataTemplate">
			<TextBlock Text="{Binding Converter={StaticResource fileNameValueConverter}}" />
		</DataTemplate>
		
		<DataTemplate x:Name="fileWithPathDataTemplate"
					  x:Key="fileWithPathDataTemplate">
			<TextBlock Text="{Binding}" />
		</DataTemplate>
		
	</Window.Resources>
    <Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" MinHeight="22" />
			<RowDefinition Height="*" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
		
		<!-- Load Directory Button-->
		<Button x:Name="loadDirectoryButton"
				Grid.Column="0"
				Grid.Row="0"
				Click="loadDirectoryButton_Click" >
			Change Directory
		</Button>
		
		<!-- Grid for file listing-->
		<Grid x:Name="fileGrid"
			  Grid.Row="1"
			  Grid.Column="0">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
				<RowDefinition Height="*" />
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="*" />
				<ColumnDefinition Width="*" />
			</Grid.ColumnDefinitions>
		
			<!-- File Label -->
			<Label Grid.Row="0"
				   Grid.Column="0">
				Files
			</Label>
		
			<!-- ItemTemplate="{StaticResource fileWithoutPathDataTemplate}"-->
			<!-- List of all current files -->
			<ListBox x:Name="fileListBox"
					 Grid.Row="1"
					 Grid.Column="0"
					 ItemsSource="{Binding}"
					 AllowDrop="True"
					 DragEnter="fileListBox_DragEnter"
					 DragOver="fileListBox_DragOver"
					 DragLeave="fileListBox_DragLeave"
					 DragDrop.Drop="fileListBox_Drop"
					 SelectionMode="Extended" 
					 KeyUp="fileListBox_KeyUp" >
				<ListBox.ContextMenu>
					<ContextMenu>
						<MenuItem x:Name="removeSelectedFilesMenuItem"
							  Click="removeSelectedFilesMenuItem_Click" 
							  Header="_Remove Selected Files" />
						<MenuItem x:Name="showFullPathMenuItem" 
								  IsCheckable="True"
								  Header="_Show Full File Paths"
								  Click="showFullPathMenuItem_Click" />
					</ContextMenu>
				</ListBox.ContextMenu>
			</ListBox>
			
			<!-- File Preview Label -->
			<Label Grid.Column="2"
				   Grid.Row="0">
				Preview
			</Label>
			
			<!-- File Preview ListBox-->
			<ListBox x:Name="previewListBox"
					 Grid.Row="1"
					 Grid.Column="2"
					 ItemsSource="{Binding}" />
			
			<!-- Grid Splitter -->
			<GridSplitter Grid.Row="0"
						  Grid.RowSpan="2"
						  Grid.Column="0"
						  Width="1"
						  Background="Blue"/>
		</Grid>
		
		<!-- Grid containing all actions to perform-->
		<Grid x:Name="actionGrid"
			  Grid.Row="2"
			  Grid.Column="0">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
				<RowDefinition Height="Auto" />
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="*" />
				<ColumnDefinition Width="2*" />
				<ColumnDefinition Width="*" />
				<ColumnDefinition Width="2*" />
			</Grid.ColumnDefinitions>
			
			
					
			<StackPanel x:Name="replaceStackPanel"
						Grid.Row="0"
						Grid.Column="0"
						Grid.ColumnSpan="2"
						Background="LightBlue"
						Orientation="Horizontal" >
					
				<CheckBox x:Name="replaceCheckBox"
						  VerticalAlignment="Center"
						  Margin="5,5,0,5"
						  Click="checkBoxClickGeneratePreview">
					Wildcard Replace (% - Wildcard)
				</CheckBox>

			</StackPanel>
					
					
			<Label x:Name="replaceBeforeLabel"
				   Grid.Row="1"
				   Grid.Column="0"
				   HorizontalContentAlignment="Right" 
				   VerticalContentAlignment="Center" >
				From:
			</Label>
					
			<TextBox x:Name="replaceBeforeTextBox"
					 Grid.Row="1"
					 Grid.Column="1" 
					 TextChanged="textChangeGeneratePreview" />
					
			<Label x:Name="replaceToLabel"
				   Grid.Row="2"
				   Grid.Column="0" 
				   HorizontalContentAlignment="Right" 
				   VerticalContentAlignment="Center">
				To:
			</Label>
			
			<TextBox x:Name="replaceToTextBox"
					 Grid.Row="2"
					 Grid.Column="1" 
					 TextChanged="textChangeGeneratePreview" />

			<StackPanel x:Name="trimStackPanel"
						Grid.Row="0"
						Grid.Column="2"
						Grid.ColumnSpan="2"
						Background="LightBlue"
						Orientation="Horizontal" >
				<Label>
					Trim
				</Label>
			</StackPanel>
						
			<CheckBox x:Name="trimStartCheckBox"
					  Grid.Row="1"
					  Grid.Column="2"
					  VerticalAlignment="Center"
					  HorizontalAlignment="Right"
					  Margin="0,5,5,5" 
					  Click="checkBoxClickGeneratePreview">
				Start
			</CheckBox>
			
			<host:WindowsFormsHost Grid.Row="1"
								   Grid.Column="3"
								   Margin="0,0,2,0">
				<forms:NumericUpDown x:Name="trimStartNumericUpDown"
									 DecimalPlaces="0"
									 Minimum="1"
									 Maximum="100"
									 TextAlign="Right" />
			</host:WindowsFormsHost>
						
			<CheckBox x:Name="trimEndCheckBox"
					  Grid.Row="2"
					  Grid.Column="2"
					  VerticalAlignment="Center"
					  HorizontalAlignment="Right"
					  Margin="0,5,9,5" 
					  Click="checkBoxClickGeneratePreview">
				End
			</CheckBox>
					
			<host:WindowsFormsHost Grid.Row="2"
								   Grid.Column="3"
								   Margin="0,0,2,0">
				<forms:NumericUpDown x:Name="trimEndNumericUpDown"
									 DecimalPlaces="0"
									 Minimum="1"
									 Maximum="100"
									 TextAlign="Right" />
			</host:WindowsFormsHost>
					
			<CheckBox x:Name="trimTheCheckBox"
					  Grid.Row="3"
					  Grid.Column="2"
					  HorizontalAlignment="Right"
					  VerticalAlignment="Center"
					  Margin="0,5,0,5" 
					  Click="checkBoxClickGeneratePreview" />
			
			<Label x:Name="trimTheLabel"
				   Grid.Row="3"
				   Grid.Column="3">
				Trim "The" from start
			</Label>
					
			<CheckBox x:Name="trimACheckBox"
					  Grid.Row="4"
					  Grid.Column="2"
					  HorizontalAlignment="Right"
					  VerticalAlignment="Center"
					  Margin="0,5,0,5" 
					  Click="checkBoxClickGeneratePreview" />
			
			<Label x:Name="trimALabel"
				   Grid.Row="4"
				   Grid.Column="3">
				Trim "A" from start
			</Label>


			<StackPanel x:Name="standardReplaceStackPanel"
							Grid.Row="3"
							Grid.Column="0"
							Grid.ColumnSpan="2"
							Background="LightBlue"
							Orientation="Horizontal" >
				<Label>
					Standard Replace
				</Label>
			</StackPanel>
					
			<CheckBox x:Name="replaceDashesCheckBox"
					  Grid.Row="4"
					  Grid.Column="0"
					  VerticalAlignment="Center"
					  HorizontalAlignment="Right" 
					  Click="checkBoxClickGeneratePreview" />
					
			<Label x:Name="replaceDashesLabel" 
				   Grid.Row="4"
				   Grid.Column="1"
				   VerticalAlignment="Center"
				   HorizontalAlignment="Left">
				Replace "-" with " - "
			</Label>
					
			<CheckBox x:Name="replaceUnderscoresCheckBox"
					  Grid.Row="5"
					  Grid.Column="0"
					  VerticalAlignment="Center"
					  HorizontalAlignment="Right" 
					  Click="checkBoxClickGeneratePreview" />
					
			<Label x:Name="replaceUnderscoresLabel" 
				   Grid.Row="5"
				   Grid.Column="1"
				   VerticalAlignment="Center"
				   HorizontalAlignment="Left" >
				Replace underscores with spaces
			</Label>
					
			<CheckBox x:Name="capitalizeCheckBox"
					  Grid.Row="6"
					  Grid.Column="0"
					  VerticalAlignment="Center"
					  HorizontalAlignment="Right" 
					  Click="checkBoxClickGeneratePreview" />
					
			<Label x:Name="capitalizeLabel" 
				   Grid.Row="6"
				   Grid.Column="1"
				   VerticalAlignment="Center"
				   HorizontalAlignment="Left">
				Captialize
			</Label>
			
			<CheckBox x:Name="toLowerCheckBox"
					  Grid.Row="7"
					  Grid.Column="0"
					  VerticalAlignment="Center"
					  HorizontalAlignment="Right"
					  Click="checkBoxClickGeneratePreview" />
			<Label x:Name="toLowerLabel"
				   Grid.Row="7"
				   Grid.Column="1"
				   VerticalAlignment="Center"
				   HorizontalAlignment="Left">
				To Lower Case
			</Label>
			
			<!-- Insert Action -->
			<StackPanel x:Name="insertStackPanel"
							Grid.Row="8"
							Grid.Column="0"
							Grid.ColumnSpan="2"
							Background="LightBlue"
							Orientation="Horizontal" >
				<CheckBox x:Name="insertCheckBox"
						  Margin="5,5,0,5"
						  Click="checkBoxClickGeneratePreview" >
					Insert At
				</CheckBox>
			</StackPanel>
			
			<Label Grid.Row="9"
				   Grid.Column="0"
				   HorizontalAlignment="Right"
				   VerticalAlignment="Center">
				Position:
			</Label>
			
			<host:WindowsFormsHost Grid.Row="9"
								   Grid.Column="1"
								   Margin="0,0,2,0">
				<forms:NumericUpDown x:Name="insertNumericUpDown"
									 DecimalPlaces="0"
									 Minimum="0"
									 Maximum="100"
									 TextAlign="Right" />
			</host:WindowsFormsHost>
			
			<Label Grid.Row="10"
				   Grid.Column="0"
				   HorizontalAlignment="Right"
				   VerticalAlignment="Center">
				Text:
			</Label>
			
			<TextBox x:Name="insertTextBox"
					 Grid.Row="10"
					 Grid.Column="1"
					 TextChanged="textChangeGeneratePreview" />
			
			
			<StackPanel x:Name="rangeRemove"
							Grid.Row="5"
							Grid.Column="2"
							Grid.ColumnSpan="2"
							Background="LightBlue"
							Orientation="Horizontal" >
				<CheckBox x:Name="rangeRemoveCheckBox"
						  Margin="5,5,0,5"
						  Click="checkBoxClickGeneratePreview" >
					Remove Range
				</CheckBox>
			</StackPanel>
			
			<Label Grid.Row="6"
				   Grid.Column="2"
				   HorizontalAlignment="Right"
				   VerticalAlignment="Center">
				Start:
			</Label>
			
			<host:WindowsFormsHost Grid.Row="6"
								   Grid.Column="3"
								   Margin="0,0,2,0">
				<forms:NumericUpDown x:Name="rangeRemoveStartNumericUpDown"
									 DecimalPlaces="0"
									 Minimum="0"
									 Maximum="99"
									 TextAlign="Right" />
			</host:WindowsFormsHost>
			
			
			
			<Label Grid.Row="7"
				   Grid.Column="2"
				   HorizontalAlignment="Right"
				   VerticalAlignment="Center">
				End:
			</Label>
			
			<host:WindowsFormsHost Grid.Row="7"
								   Grid.Column="3"
								   Margin="0,0,2,0">
				<forms:NumericUpDown x:Name="rangeRemoveEndNumericUpDown"
									 DecimalPlaces="0"
									 Minimum="1"
									 Maximum="100"
									 TextAlign="Right" />
			</host:WindowsFormsHost>
			
			

					
			<!-- Apply Actions Button -->
			<Button x:Name="applyButton"
					Grid.Row="8"
					Grid.RowSpan="2"
					Grid.Column="2"
					Grid.ColumnSpan="2"
					Click="applyButton_Click" 
					Height="30"
					Width="100">
				Rename
			</Button>
			
			
			
			<Border BorderBrush="Blue" 
					BorderThickness="1"
					Grid.Row="0"
					Grid.Column="0"
					Grid.RowSpan="3"
					Grid.ColumnSpan="2" />
			
			<Border BorderBrush="Blue"
					BorderThickness="1"
					Grid.Row="0"
					Grid.Column="2"
					Grid.RowSpan="5"
					Grid.ColumnSpan="2" />
			
			<Border BorderBrush="Blue"
					BorderThickness="1"
					Grid.Row="3"
					Grid.Column="0"
					Grid.RowSpan="5"
					Grid.ColumnSpan="2" />
			
			<Border BorderBrush="Blue"
					BorderThickness="1"
					Grid.Row="5"
					Grid.Column="2"
					Grid.RowSpan="3"
					Grid.ColumnSpan="2" />
			
			<Border BorderBrush="Blue"
					BorderThickness="1"
					Grid.Row="8"
					Grid.Column="0"
					Grid.RowSpan="3"
					Grid.ColumnSpan="2" />
					
		</Grid>
		
	</Grid>
	
</Window>
